package com.wcy.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.wcy.annotation.pageVo.MappingColumn;
import com.wcy.annotation.pageVo.PageColumn;
import com.wcy.annotation.pageVo.PageName;
import lombok.*;
import lombok.experimental.Accessors;

import java.util.List;

/**
 * <p>
 * 
 * </p>
 *
 * @author 吴传亿
 * @since 2025-04-29
 */
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@ToString
@Accessors(chain = true)
@PageName(name = "角色")
public class Role {

    @PageColumn(isId = true,prop="roleId", label="角色ID",allowEdit = false)
    @TableId(value = "role_id", type = IdType.AUTO)
    private Integer roleId;

    @PageColumn(prop="roleName", label="角色名")
    private String roleName;

    @PageColumn(prop="description", label="角色描述")
    private String description;

    @PageColumn(prop="isDefaultRole",label = "默认用户角色",type = "toggle")
    private Boolean isDefaultRole;

    @TableField(exist = false)
    @PageColumn(prop="permissions",label = "角色权限",type="mapping",mappingRef = @MappingColumn(targetProp = "roleId", mappingByPropUrl = "rolePermission/list",mappingListUrl = "permission/list", mappingListProp = "permissionId",mappingListLabel = "description"))
    private List<Permission> permissions;

    public Role(Integer roleId){
        this.roleId = roleId;
    }
}
